package com.example.webdome.util;

import org.springframework.stereotype.Component;

@Component
public class getCookie {
    /**
     * 将token从cookievalue中分离出来
     * @param cookieValue
     * @return token
     */
    public String getCookieValue(String cookieValue) {
        if (cookieValue != null) {
            String token = null;
            for (String cookie : cookieValue.split(";")) {
                String[] parts = cookie.trim().split("=");
                if (parts.length == 2 && parts[0].equals("token")) {
                    token = parts[1];
                    return token;
                }
            }
        }
        return "";
    }
}
